'''
Created on Jul 9, 2011

@author: kafkef
'''

from PyQt4.QtGui import *

from PyQt4.QtCore import Qt

from dexen.system.client import ui

from dexen.system.client.proxy import JobProxy
from dexen.system.client.ui.pages.job_log_page import JobLogPage
from dexen.system.client.ui.pages.job_info_page import JobInfoPage
from dexen.system.client.ui.pages.job_output_page import JobOutputPage
from dexen.system.client.ui.pages.job_pareto_page import JobParetoPage
from dexen.system.client.ui.pages.job_advance_page import JobAdvancePage
from dexen.system.client.ui.pages.job_progress_page import JobProgressPage


svr_proxy = ui.svr_proxy


class JobTabWidget(QTabWidget):
    def __init__(self):
        QTabWidget.__init__(self)
        self._cur_focused_job = None
        self._create_pages()
        self._add_tabs()
        
    def _create_pages(self):
        self._job_info_page = JobInfoPage()
        self._job_log_page = JobLogPage()
        self._job_output_page = JobOutputPage()
        self._job_pareto_page = JobParetoPage()
        self._job_progress_page = JobProgressPage()
        self._job_advancement_page = JobAdvancePage()
        
    def _add_tabs(self):
        self.addTab(self._job_info_page, "Job Info")
        self.addTab(self._job_log_page, "Job Log")
        self.addTab(self._job_output_page, "Job Output")
        self.addTab(self._job_pareto_page, "Job Pareto")
        self.addTab(self._job_progress_page, "Job Progress")
        self.addTab(self._job_advancement_page, "Job Advancement")
    
    def on_cur_job_changed(self, job_id):
        print "JobTabWidget:on_cur_job_changed"
        self._job_info_page.update_cur_job_id(job_id)
        self._job_output_page.update_cur_job_id(job_id)
        self._job_log_page.update_cur_job_id(job_id)
        self._job_pareto_page.update_cur_job_id(job_id)
        self._job_progress_page.update_cur_job_id(job_id)
        self._job_advancement_page.update_cur_job_id(job_id)
        
    def on_refresh(self):
        self._job_info_page.on_refresh()
        self._job_output_page.on_refresh()
        self._job_log_page.on_refresh()
        self._job_pareto_page.on_refresh()
        self._job_progress_page.on_refresh()
        self._job_advancement_page.on_refresh()
        

